<template>
  <div>
    <el-form :inline="true" :model="formData" size="mini" class="demo-form-inline" v-if="formItem.length">
      <el-form-item :label="item.label" v-for="(item, index) in formItem" :key="index">
        <el-input v-if="item.type === 'input'" v-model="formData[item.name]" clearable maxlength="30"></el-input>
        <el-select v-else-if="item.type === 'select'" v-model="formData[item.name]" clearable>
          <el-option :label="item2.label" :value="item2.value" v-for="(item2, index) in item.options" :key="index"></el-option>
        </el-select>
        <el-date-picker
          v-else-if="item.type === 'datetime'"
          v-model="formData[item.name]"
          type="datetime"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleSearch">查询</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    // 表单参数
    formData: {
      type: Object,
      default: () => {}
    },
    // 表单查询字段
    formItem: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {}
  },
  methods: {
    // 查询按钮
    handleSearch () {
      this.$emit('handleSearch', this.formData)
    }
  }
}
</script>
